/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.registration.gui.security;

import it.polimi.registration.business.security.boundary.InviteManager;
import it.polimi.registration.business.security.entity.Invite;
import it.polimi.registration.business.security.entity.InviteStatus;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

/**
 *
 * @author Stefano
 */
@Named
@RequestScoped
public class InviteBean {

    @EJB
    private InviteManager im;
    
    private Invite invite;
    
    public Invite getInvite() {
        if (invite == null) {
            invite = new Invite();
        }
        return invite;
    }
    
    public void setInvite(Invite invite){
        this.invite=invite;
    }
    
    public void save(Invite invite){
        im.save(invite);
    }
    
    public void accept(Invite invite){
        invite.setStatus(InviteStatus.ACCEPTED);
        im.update(invite);
    }
    
    public void decline(Invite invite){
        invite.setStatus(InviteStatus.DECLINED);
        im.update(invite);
    }
}
